package com.hp.controller;

import com.hp.req.ChatMemoryReq;
import com.hp.vo.ChatMemoryVO;
import com.hp.service.ChatService;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @author hp
 */
@RestController
@RequestMapping("/ai")
public class ChatController {

    @Resource
    private ChatService chatService;


    @GetMapping("/normalCompletion")
    public String normalCompletion(@RequestParam(value = "message", defaultValue = "Tell me a joke") String message) {

        return chatService.normalCompletion(message);
    }

    @GetMapping("/streamCompletion")
    public Map<String, String> streamCompletion(@RequestParam(value = "message", defaultValue = "请告诉我西红柿炖牛腩怎么做？") String message) {

        return chatService.streamCompletion(message);
    }


    @GetMapping("/image/{input}")
    public void image(@PathVariable("input") String input, HttpServletResponse response) {
        chatService.image(input, response);
    }

    @GetMapping("/chatMemoryByList")
    public String chatMemoryByList(@RequestParam("systemMessage") String systemMessage, @RequestParam("userMessage") String userMessage) {
        return chatService.chatMemoryByList(systemMessage, userMessage);
    }

    @PostMapping("/chatMemory")
    public ChatMemoryVO chatMemory(@RequestBody ChatMemoryReq chatMemoryReq) {
        return chatService.chatMemory(chatMemoryReq);
    }


}
